home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Graphic Elements 3 / GEDemo / Sign.c < prev    next >
Text File  |  1994-09-24  |  2KB  |  85 lines

  1. /*
  2.     Sign.c
  3.     
  4.     User-entered text for Graphic Elements demo
  5.     
  6.     Copyright 1993 by Al Evans. All rights reserved.
  7.     
  8.     11/11/93
  9.     
  10. */
  11.  
  12. #include "Sign.h"
  13.  
  14. Str255    signText = "\pMessage Here!";
  15. typedef struct {
  16.             Boolean signOn;
  17.             RGBColor color[2];
  18. } BlinkRec, *BlinkRecPtr;
  19.  
  20. //BlinkRec    signBlink;
  21.  
  22. pascal void DisposeSign(GEWorldPtr world, GrafElPtr element)
  23. {
  24.     if (element->changeData)
  25.         DisposPtr(element->changeData);
  26. }
  27.  
  28. Boolean LoadSignScene(GEWorldPtr world)
  29. {
  30.     GrafElPtr        thisElement;
  31.     short            fontNum;
  32.     BlinkRecPtr        signBlink;
  33.     
  34.     GetFNum("\pChicago", &fontNum);
  35.     
  36.     signBlink = (BlinkRecPtr) NewPtr(sizeof(BlinkRec));
  37.     
  38.     signBlink->signOn = false;
  39.     signBlink->color[0].red = 194 << 8;
  40.     signBlink->color[0].green = 194 << 8;
  41.     signBlink->color[0].blue = 0;
  42.     signBlink->color[1].red = 240 << 8;
  43.     signBlink->color[1].green = 240 << 8;
  44.     signBlink->color[1].blue = 46 << 8;
  45.     
  46.     //Create sign
  47.     thisElement = NewTextGraphic(world, signID, signPlane, signLeft, signTop, srcOr,
  48.                             fontNum, bold, 18, signBlink->color[signBlink->signOn], signText);
  49.     if (!thisElement) return false;
  50.     
  51.     //Initialize blinking action
  52.     SetAutoChange(world, signID, DoSign, (Ptr) signBlink, 750);
  53.     
  54.     //Be sure to Dispose blink record
  55.     SetCleanupProc(world, signID, DisposeSign);
  56.     
  57.     return true;
  58.                     
  59. }
  60.  
  61. pascal void DoSign(GEWorldPtr world, GrafElPtr sign)
  62. {
  63. #pragma unused (world)
  64.     BlinkRecPtr    blink;
  65.     
  66.     blink = (BlinkRecPtr) sign->changeData;
  67.     
  68.     blink->signOn = !blink->signOn;
  69.     ((TextGraphicPtr) sign)->tgColor = blink->color[blink->signOn];
  70.     ChangedRect(world, &sign->animationRect);
  71. }
  72.  
  73. pascal void GetSignText(StringPtr oldText)
  74. {
  75.     BlockMove((Ptr) signText, (Ptr) oldText, (long) *signText + 1);
  76. }
  77.  
  78. //Change sign text
  79. pascal void SetSignText(GEWorldPtr world, StringPtr newText)
  80. {
  81.     BlockMove((Ptr) newText, (Ptr) signText, (long) *newText + 1);
  82.     SetTextGraphicText(world, signID, signText);
  83. }
  84.  
  85.